//
//  CagooConfig.m
//  Cagoo
//
//  Created by brice rouanet on 02/02/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CagooConfig.h"


@implementation CagooConfig



-(BOOL)isCagooEnabled
{	
	NSArray *stringEnabled;

	//read conf file and check is it contain something
	if ([self readAllConf] == FALSE || [allConfig count] <= 0) {
		return FALSE;
	}
	
	stringEnabled = [[allConfig objectAtIndex:0] componentsSeparatedByString:@"="];
	if ([[stringEnabled objectAtIndex:0] isEqualToString:@"cagooEnabled"] && [[stringEnabled objectAtIndex:1] isEqualToString:@"TRUE"])
	{
		return TRUE;
	}

	
	return FALSE;
}

-(BOOL)readAllConf
{
	
	//read conf file
	allConfig = [[NSArray alloc]initWithContentsOfFile:@"/Library/Application Support/Cagoo/cagoo.conf"];
	tableContent = [[NSMutableArray alloc] init];  
	[tableContent addObjectsFromArray:allConfig];
	
	
	return TRUE;
	
}

-(void)saveConf:(NSArray *)buffer
{
	//write file
	[buffer writeToFile:@"/Library/Application Support/Cagoo/cagoo.conf" atomically:YES];
	[self readAllConf];

}
@end
